package licode.unisop.types.dp;

import org.springframework.util.Assert;

/**
 * 菜单类型
 */
public class UserType {

    public static final UserType SYSTEM = new UserType(1);
    public static final UserType NORMAL = new UserType(0);

    private final int type;

    private UserType(int type) {
        this.type = type;
    }

    public static UserType build(int type) {
        Assert.isTrue(type == 1 || 0 == type,
                "用户类型取值0或1，当前：" + type);
        if (SYSTEM.type == type) {
            return UserType.SYSTEM;
        }
        return UserType.NORMAL;
    }

    public boolean isSystem() {
        return (SYSTEM.type == type);
    }

    public boolean isNormal() {
        return (NORMAL.type == type);
    }

    public int getType() {
        return type;
    }

    @Override
    public String toString() {
        return isSystem() ? "system" : "normal";
    }
}
